package com.zzg.srb.core.controller.api;


import com.zzg.srb.base.utils.JwtUtils;
import com.zzg.srb.common.result.R;
import com.zzg.srb.core.entity.vo.BorrowerVo;
import com.zzg.srb.core.service.BorrowerService;
import com.zzg.srb.core.utils.CurrentLoginUserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;


/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author zhengzg
 * @since 2022-05-27
 */
@Api(tags = "借款人")
@RestController
@RequestMapping("/api/core/borrower")
public class BorrowerController {

    private final Logger log = LoggerFactory.getLogger(BorrowerController.class);

    @Resource
    private BorrowerService borrowerService;

    @ApiOperation("保存借款人信息")
    @PostMapping("/auth/save")
    public R save(@RequestBody BorrowerVo borrowerVo){
        log.info("保存借款人信息接口 ========》 BorrowerController.save：" +borrowerVo );
        Long userId = CurrentLoginUserUtils.getLoginUser();
        borrowerService.saveBorrowerVoByUserId(borrowerVo,userId);
        return R.ok().message("信息提交成功");
    }

    @ApiOperation("获取借款人认证状态")
    @GetMapping("/auth/getBorrowerStatus")
    public R getBorrowerStatus(){
        log.info("获取借款人状态接口 ==========》 BorrowerController。getBorrowerStatus");
        Long userId = CurrentLoginUserUtils.getLoginUser();
        Integer status = borrowerService.getStatusByUserId(userId);
        return R.ok().data(status);
    }

}

